<%-- 
    Document   : emp_file
    Created on : Dec 19, 2013, 12:55:49 AM
    Author     : zraj
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script type="text/javascript">
            function goto(src)
            {
                //  alert(src);
                window.open(src);
            }

            function deleteFile(fileId)
            {
                if (confirm("ลบข้อมูลนี้ ?") == true)
                {
                    $('#hidFileId').val(fileId);

                    $('#empFileDelete').submit();
                }
            }

        </script>
    </head>
    <body>
        <!-- CSS goes in the document HEAD or added to your external stylesheet -->
        <style type="text/css">
            table.gridtable {
                font-family: verdana,arial,sans-serif;
                font-size:11px;
                color:#333333;
                border-width: 1px;
                border-color: #666666;
                border-collapse: collapse;
            }
            table.gridtable th {
                border-width: 1px;
                padding: 8px;
                border-style: solid;
                border-color: #666666;
                background-color: #dedede;
            }
            table.gridtable td {
                border-width: 1px;
                padding: 8px;
                border-style: solid;
                border-color: #666666;
                background-color: #ffffff;
            }
        </style>
        <!-- Table goes in the document BODY -->

        <s:if test="%{files.size() > 0}" >
            <table class="gridtable">
                <tr>
                    <th>ประเภทไฟล์</th><th>อัพโหลดโดย</th><th>เวลา</th><th></th><th></th>
                </tr>

                <s:iterator value="files" status="stat">
                    <tr>
                        <td><s:property value="fileType"></s:property></td>
                        <td><s:property value="createBy"></s:property></td>
                        <td><s:date name="createOn" format="dd-MM-yyyy HH:mm:ss" var="createDt"></s:date>
                            <s:property value="createDt"></s:property>
                            </td>

                            <td>


                            <sj:a   href="#" button="true" onclick="goto('upload/%{fileName}')"  cssStyle="color:white;" >download</sj:a></td>
                        <td> <sj:a href="#" button="true" onclick="deleteFile(%{fileId})"  cssStyle="color:white;" >delete</sj:a></td>
                        </tr>
                </s:iterator>

            </table>
        </s:if>
        <s:actionerror />
        <s:form id="empFileDelete" action="empFileDelete" method="post">
            <s:hidden id="hidFileId" name="fileIdDelete" value=""></s:hidden>
        </s:form>
        <s:form action="empFileAdd" method="post" enctype="multipart/form-data">
            <table>
                <tr><td>ประเภทไฟล์</td><td><select name="fileType">
                            <option value="สำเนาบัตรประชาชน">สำเนาบัตรประชาชน</option>
                            <option value="สำเนาทะเบียนบ้าน">สำเนาทะเบียนบ้าน</option>
                            <option value="อื่นๆ">อื่นๆ</option>
                        </select></td></tr>
                <tr>
                    <td> <s:file name="fileUpload" label="Employee File" /></td><td> <s:submit value="Upload" align="center" /></td>
                </tr>
            </table>



        </s:form>
    </body>
</html>
